from Python_Uiautomator_Auto.utils.common_actions import scroll_and_click, verify_text_exists,click_element


class HomePage:
    def __init__(self, d):
        self.d = d

    def open_settings(self):
        self.d.app_start("com.android.settings")
        time.sleep(2)

    def verify_title(self):
        verify_text_exists(self.d, "设置")

    def verify_search_box(self):
        verify_text_exists(self.d, "搜索系统设置项")

    def verify_user_account(self):
        verify_text_exists(self.d, "君泺荣光")

        # verify_text_exists(self.d, "管理账号、云服务、会员权益等")

    def verify_device_info(self):
        verify_text_exists(self.d, "我的设备")

    def verify_wlan(self):
        verify_text_exists(self.d, "WLAN")
    def verify_bluetooth(self):
        verify_text_exists(self.d, "蓝牙")

    def verify_mobile_network(self):
        verify_text_exists(self.d, "移动网络")

    def verify_more_connectivity(self):
        verify_text_exists(self.d, "互联互通")
    def verify_vpn(self):
        verify_text_exists(self.d, "VPN")

    def verify_more_connection(self):
        verify_text_exists(self.d, "更多连接")

    def verify_system_info(self):
        verify_text_exists(self.d, "系统个性化")

    def verify_lock_screen(self):
        verify_text_exists(self.d, "锁屏")

    def verify_notification_and_status_bar(self):
        verify_text_exists(self.d, "通知与状态栏")
    # 桌面
    def verify_desktop(self):
        verify_text_exists(self.d, "桌面")
    # 显示与亮度
    def verify_display_and_brightness(self):
        verify_text_exists(self.d, "显示与亮度")
    # 声音与触感
    def verify_sound_and_touch(self):
        verify_text_exists(self.d, "声音与触感")

    # 指纹、面部与密码
    def verify_biometric_and_password(self):
        verify_text_exists(self.d, "指纹、面部与密码")

    # 隐私与安全
    def verify_privacy_and_security(self):
        verify_text_exists(self.d, "隐私与安全")

    # 应用设置
    def verify_app_settings(self):
        verify_text_exists(self.d, "应用设置")
    # 省电与电池
    def verify_power_and_battery(self):
        verify_text_exists(self.d, "省电与电池")

    def verify_health_use_phone(self):
        verify_text_exists(self.d, "健康使用手机")
    # 小爱同学
    def verify_xiaoai(self):
        verify_text_exists(self.d, "小爱同学")
    # 更多设置
    def verify_more_settings(self):
        verify_text_exists(self.d, "更多设置")
    # 问题反馈
    def verify_feedback(self):
        verify_text_exists(self.d, "问题反馈")

    def click_item_name(self,item_name):
        self.d(text=item_name).click()


    def click_setting_item(self, item_name):
        # scroll_and_click(self.d, item_name)d(resourceId="android:id/input").click()
        # click_element(self.d,)
        self.d(resourceId="android:id/input", text=item_name).click()

    def verify_status_switch(self):
        # 假设这里查找蓝牙开关控件
        switch = self.d(resourceId="android:id/widget_frame")
        return switch  # 返回 u2.UiObject 对象















